package com.xhui.service;

import com.xhui.entity.Book;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;

@SpringBootTest
public class BookServiceTestCase {

    @Resource
    private BookService bookService;

    @Test
    void testGetAll(){
        bookService.getAll();
    }

    @Test
    void testGetById(){
        System.out.println( bookService.getById(4) );
    }

    @Test
    void testSave(){
        Book book = new Book();
        book.setType("测试数据类型");
        book.setName("测试数据名称123");
        book.setDescription("测试数据描述");
        bookService.save(book);
    }

    @Test
    void testGetPage(){
        System.out.println(bookService.getPage(1, 5).getRecords());
    }

    @Test
    void testUpdate(){
        Book book = new Book();
        book.setId(12);
        book.setName("testdata1");
        book.setType("testdata1");
        book.setDescription("testdata1");
        System.out.println("result: " + bookService.update(book) );
    }

    @Test
    void testDelete(){
        bookService.delete(12);
    }

}
